<template>
  <div class="app-container">
    <eHeader :param-bean="paramBean" :sup_this="sup_this" />
    <eForm ref="form" :sup_this="sup_this" />
    <historyList ref="historyList" :sup_this="sup_this" />
    <!--表格渲染-->
    <DataGridTable
      v-loading="loading"
      ref="mainTable"
      :sup_this="sup_this"
      :data="data.rtnList"
      :max-height="gridMaxHeight"
      :total="total"
      :show-cell-class="true"
      :show-row-complex-number="true"
      :all-define-columns="['sysOrgName','busDate','prodItemCode','mrpQty','selfStateName','bomCode','orderCode','busRmk','autoFlag','lastUpdateDate']"
      grid-id="mrpMngProcessGridId"
      @toViewHistory="toViewHistory"
      @selection-change="handleGridSelectionChange">
      <DataGridColumnSlot prop="sysGenCode" label="业务类型">
        <template slot-scope="scope">
          <edit :data="scope.row" :sup_this="sup_this" />
        </template>
      </DataGridColumnSlot>
      <DataGridColumn slot="sysOrgName" prop="sysOrgName" label="机构" />
      <DataGridColumnSlot slot="busDate" prop="busDate" label="业务时间">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.busDate) }}</span>
        </template>
      </DataGridColumnSlot>
      <DataGridColumn slot="prodItemCode" prop="prodItemCode" label="产品编号" />
      <DataGridColumn slot="mrpQty" prop="mrpQty" label="生产数" />
      <DataGridColumn slot="selfStateName" prop="selfStateName" label="状态"/>
      <DataGridColumn slot="bomCode" prop="bomCode" label="BOM编码" />
      <DataGridColumn slot="orderCode" prop="orderCode" label="订单号" />
      <DataGridColumn slot="busRmk" prop="busRmk" label="备注"/>
      <DataGridColumn slot="autoFlag" prop="autoFlag" label="自动生成"/>
      <DataGridColumnSlot slot="lastUpdateDate" prop="lastUpdateDate" label="最后更新时间" >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.lastUpdateDate) }}</span>
        </template>
      </DataGridColumnSlot>
    </DataGridTable>
  </div>
</template>

<script>
import { parseTime } from '@/utils/index'
import eHeader from './module/header'
import edit from './module/edit'
import eForm from './module/form'
import historyList from './module/historyList'
import initData from '@/mixins/initData'
import mrp from '@/api/prod/Mrp'

export default {
  components: { eHeader, eForm, edit, historyList },
  mixins: [initData],
  props: {
  },
  data() {
    return {
      delLoading: false,
      sup_this: this
    }
  },
  created() {
    this.url = mrp.loadDataUrl()
    this.defaultParamBean.selfStateList = ['0', '5', '4', '10'] // 默认加载草稿，待审批，审批不通过的数据
    this.$nextTick(() => {
      this.resetQuery(true)
    })
  },
  mounted() {
  },
  methods: {
    parseTime,
    toViewHistory(row) {
      this.openViewHistory(row, 'historyList')
    },
    async beforeInit() {
      return true
    }
  }
}
</script>
